#include <func.h>

int main(int argc,char*argv[])
{
    ARGS_CHECK(argc ,2);
    struct hostent *p;
    p=gethostbyname(argv[1]);
    if(NULL==p)
    {
        printf("gethostbyname is failed\n");
        return -1;
    }
    printf("正式主机名=%s\n主机ip地址类型%d\n主机IP地址字节长度%d\n",p->h_name,p->h_addrtype,p->h_length);
    int i;
    for(i=0;p->h_aliases[i]!=NULL;i++)
    {
        printf("主机别名%d:%s\n",i+1,p->h_aliases[i]);
    }
    for(i=0;p->h_addr_list[i]!=NULL;i++)
    {
        char buf[100]={0};
        inet_ntop(p->h_addrtype,p->h_addr_list[i],buf,sizeof(buf));
        printf("主机ip地址列表%d:%s\n",i+1,buf);
    }
    return 0;
}